<template>
  <el-dropdown trigger="click" @command="toggleLanguage">
    <div>
      <svg-icon icon-class="language" style="color:#fff; width: 20px; height: 20px;cursor:pointer;" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="_i18n.locale === 'zh'">中文简体</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="_i18n.locale === 'en'">English</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  name: 'Language',
  methods: {
    toggleLanguage(type) {
      // 切换语言
      Cookie.set('language', type)
      this._i18n.locale = type
      this.$message.success('切换语言成功')
    }
  }
}
</script>

<style>

</style>
